package com.zsz.springboot.web;


import com.zsz.springboot.model.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class UserController {

    @RequestMapping(value = "/user/detail")
    public ModelAndView userDetail(){

        ModelAndView mv=new ModelAndView();

        User user = new User();
        user.setId(1001);
        user.setAge(23);
        user.setName("lisi");

        mv.setViewName("userDetail");
        mv.addObject("user",user);


        return mv;

    }


    @RequestMapping(value = "/url")
    public String urlExpression(Model model){


        model.addAttribute("id",1001);
        model.addAttribute("name","lisi");
        model.addAttribute("age",25);


        return "url";



    }


    @RequestMapping(value = "/test")
    public @ResponseBody String test(String name){

        return "请求路径/test，参数是："+name;

    }



    @RequestMapping(value = "/test1")
    public @ResponseBody String test(Integer id,String name,Integer age){

        return "请求路径/test1，参数id="+id+",name="+name+",age="+age;

    }












}
